package org.edu.modules.sxjy.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import org.edu.common.api.vo.Result;
import org.edu.common.aspect.annotation.AutoLog;
import org.edu.common.system.base.controller.BaseController;
import org.edu.modules.sxjy.entity.VeAppUser;
import org.edu.modules.sxjy.service.IVeAppUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author leidq
 * @create 2022-04-08 10:17
 */
@Api(tags={"用户信息"})
@RestController
@RequestMapping("/sxjy/veAppUser")
@ApiSort(60)
public class VeAppUserController
        extends BaseController<VeAppUser, IVeAppUserService>
{
    private static final Logger log = LoggerFactory.getLogger(VeAppUserController.class);
    @Autowired
    private IVeAppUserService veAppUserService;

    @AutoLog("用户信息-新增信息")
    @ApiOperation(value="新增信息", notes="用户信息-新增信息")
    @PostMapping({"/add"})
    public Result<?> add(@RequestBody VeAppUser veAppUser)
    {
        this.veAppUserService.save(veAppUser);
        return Result.OK("添加成功！");
    }

    @AutoLog("用户信息-修改信息")
    @ApiOperation(value="修改信息", notes="用户信息-修改信息")
    @PutMapping({"/edit"})
    public Result<?> edit(@RequestBody VeAppUser veAppUser)
    {
        this.veAppUserService.updateById(veAppUser);
        return Result.OK("编辑成功!");
    }

    @AutoLog("用户信息-通过id删除")
    @ApiOperation(value="通过id删除", notes="用户信息-通过id删除")
    @DeleteMapping({"/delete"})
    public Result<?> delete(@RequestParam(name="id", required=true) String id)
    {
        this.veAppUserService.removeById(id);
        return Result.OK("删除成功!");
    }

    @AutoLog("用户信息-批量删除")
    @ApiOperation(value="批量删除", notes="用户信息-批量删除")
    @DeleteMapping({"/deleteBatch"})
    public Result<?> deleteBatch(@RequestParam(name="ids", required=true) String ids)
    {
        this.veAppUserService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
}

